<template>
  <div>
    <input placeholder="输入关键字搜索" v-model="searchKeyWords" />
      <MyCase :list="renderList" @Desc="Desc"/>
      <XiangQing :flag="flag" @close="close" :list1="list1"/>
  </div>
</template>

<script>
import MyCase from '@/components/MyCase.vue';
import XiangQing from '@/components/XiangQing.vue';
export default {
  components: {
    MyCase,
    XiangQing
  },

  data() {
    return {
      flag:false,
      searchKeyWords: '',
      list1:{},
      list: [
        {
          date: '2022-01-01',
          doctor: '张三',
          diagnosis: '感冒',
          prescription: '感冒药',
        },
        {
          date: '2022-02-01',
          doctor: '李四',
          diagnosis: '头疼',
          prescription: '止疼药',
        },
        {
          date: '2022-03-01',
          doctor: '王五',
          diagnosis: '腰痛',
          prescription: '止痛贴',
        },
      ],
    };
  },

  computed: {
    renderList() {
      return this.list.filter((item) => {
        return (
          item.date.includes(this.searchKeyWords) ||
          item.doctor.includes(this.searchKeyWords) ||
          item.diagnosis.includes(this.searchKeyWords) ||
          item.prescription.includes(this.searchKeyWords)
        );
      });
    },
  },
  methods:{
    Desc(id) {
        // console.log(id);
        this.flag=true;
        this.list1={...id}
        // console.log(this.list1);
    },
    close(){
      this.flag = false
    }
  }
};
</script>

<style scoped></style>
